﻿using AwesomeChromeFormUI.Attributes;
using AwesomeChromeFormUI.Configs;
using AwesomeChromeFormUI.Interfaces;
using CefSharp.WinForms;
using System;
using System.IO;

namespace ExampleApp.Configs
{
    [CefConfigurationAttribute]
    public class CustomCefConfig : ICefConfiger
    {
        public CefConfiguration CreateCustomCefConfiguration()
        {
            CefSettings settings = new CefSettings()
            {
                AcceptLanguageList= "zh-CN,zh;q=0.9",
                LocalesDirPath= @"D:\MyCodeSpace\acfui\ExampleWinFormApp\bin\Debug\locales",
                LogFile= @"D:\MyCodeSpace\acfui\ExampleWinFormApp\bin\Debug\logfile.log",
                Locale = "zh-CN",
                //LogSeverity = LogSeverity.Verbose,
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };

            // 远程调试
            settings.RemoteDebuggingPort = 8090;

            settings.CefCommandLineArgs.Add("enable-media-stream");
            settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
            settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");
            //settings.RegisterScheme(new CefCustomScheme
            //{
            //    SchemeName = "http",
            //    DomainName = "yushanma.acf",
            //    SchemeHandlerFactory = new FolderSchemeHandlerFactory(rootFolder: @"../../Frontend/dist",
            //             hostName: "yushanma.acf", //Optional param no hostname/domain checking if null
            //             defaultPage: "index.html") //Optional param will default to index.html
            //});

            return new CefConfiguration()
            {
                CefSettings = settings,
                PerformDependencyCheck = true,
                BrowserProcessHandler = null
            };
            
        }
    }
}
